﻿Public Class Programmatismenes
    Private ms As Base.Entities.Moira()
    Private stratef As Base.SortableCollection(Of Base.Entities.StaffProgram)
    Private staff As Base.SortableCollection(Of Base.Entities.Staff)
    Private serviceTypes() As Base.Entities.ServiceType
    Private programmatismenes As Base.SortableCollection(Of Base.Entities.StaffProgram)
    'Private deleteThese As List(Of Integer)

    Private Sub Programmatismenes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ms = My.Connector.Client.Moires
        ListBox1.DataSource = ms
        ListBox1.DisplayMember = "Name"
        serviceTypes = My.Connector.Client.ServiceType
        Dim serviceTypesList As New List(Of Base.Entities.ServiceType)
        serviceTypesList.AddRange(serviceTypes)
        serviceTypesList.Add(New Base.Entities.ServiceType(0, "(empty)"))
        serviceTypes = serviceTypesList.ToArray
    End Sub



    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
        Dim selectedMoires As New List(Of Base.Entities.Moira)

        For Each i In ListBox1.SelectedItems
            selectedMoires.Add(i)
        Next

        stratef = My.Connector.Client.Programmatismenes(selectedMoires.ToArray)
        staff = My.Connector.Client.StaffSelection(selectedMoires.ToArray)
        staff.Add(New Base.Entities.Staff)

        dgvProgrammatismenes.Columns.Clear()
        dgvProgrammatismenes.DataSource = stratef
        dgvProgrammatismenes.Columns.Remove(dgvProgrammatismenes.Columns("StaffId")) '.CellTemplate = New DataGridViewComboBoxCell
        dgvProgrammatismenes.Columns.Remove(dgvProgrammatismenes.Columns("ServiceType")) '.CellTemplate = New DataGridViewComboBoxCell
        dgvProgrammatismenes.Columns("Id").Visible = False

        Dim staffColumn As New DataGridViewComboBoxColumn
        With staffColumn
            .DataPropertyName = "StaffId"
            .HeaderText = "Στρατεύσιμος"
            .DropDownWidth = 160
            .Width = 90
            .MaxDropDownItems = 4
            .FlatStyle = FlatStyle.Flat
            .DataSource = staff
            .ValueMember = "Id"
            .DisplayMember = "StaffName" '"Description"
        End With

        Dim serviceColumn As New DataGridViewComboBoxColumn
        With serviceColumn
            .DataPropertyName = "ServiceType"
            .HeaderText = "Υπηρεσία"
            .DropDownWidth = 160
            .Width = 90
            .MaxDropDownItems = 4
            .FlatStyle = FlatStyle.Flat
            .DataSource = serviceTypes
            .ValueMember = "Id"
            .DisplayMember = "Description"
        End With

        Dim programmatismenes As New DataGridViewComboBoxColumn
        With programmatismenes
            .DataPropertyName = "Programmatismenes"
            .HeaderText = "Ημερομηνία"
            .DropDownWidth = 160
            .Width = 90
            .MaxDropDownItems = 4
            .FlatStyle = FlatStyle.Flat
            .DataSource = programmatismenes
            .ValueMember = "Id"
            .DisplayMember = "Hmeromhnia"
        End With

        'deleteThese = New List(Of Integer)
        dgvProgrammatismenes.Columns.Insert(0, staffColumn)
        dgvProgrammatismenes.Columns.Insert(1, serviceColumn)
        dgvProgrammatismenes.Columns.Insert(2, Programmatismenes)

        dgvProgrammatismenes.DataSource = stratef
    End Sub
End Class